Skip to content

Capture server.Serve() error in OAuth authorization flow#67

Merged
telegrapher merged 3 commits into
mainfrom
fix/capture-serve-error
Feb 27, 2026
Merged

Capture server.Serve() error in OAuth authorization flow#67
telegrapher merged 3 commits into
mainfrom
fix/capture-serve-error

Conversation

@telegrapher

Copy link
Copy Markdown
Collaborator

Summary

  • Capture Serve() error. server.Serve(listener) ran in a goroutine with its error discarded. If Serve failed, the select would block until the 5-minute timeout with a generic "user timed out" error instead of reporting the actual cause. Now captured via a buffered channel and added as a select case for immediate feedback.

  • Buffered channel by design. In the normal flow, Serve returns http.ErrServerClosed after Shutdown(), when nobody is reading from the channel. A buffered channel (capacity 1) ensures the goroutine can always write and exit without leaking.

  • Add documentation. docs/oauth-serve-error.md explains the pattern, practical likelihood, and why the channel must be buffered.

server.Serve() ran in a goroutine with its error discarded. If Serve
failed, the select would block until the 5-minute timeout instead of
reporting the actual error. Capture the error via a buffered channel
and add it as a case in the select for immediate feedback.
Replace the output package with cmd/pretty. The new pretty.JSON()
function returns a prettified string instead of printing directly,
letting callers handle their own output.

Move prettifying out of ims/decode.go — DecodeToken now returns raw
JSON strings, and cmd/decode.go applies pretty.JSON before printing.

Remove unused DecodedToken.Signature field.
Refactor pretty-print JSON into cmd/pretty package
@telegrapher
telegrapher merged commit d19f07f into main Feb 27, 2026
5 checks passed
@telegrapher
telegrapher deleted the fix/capture-serve-error branch February 28, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants